package com.briup.sms.web.controller;

import com.briup.sms.entity.Admin;
import com.briup.sms.service.AdminService;
import com.briup.sms.utils.Result;
import com.briup.sms.utils.SMSException;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author :xuyang
 * @DateTime:2024/1/10 11:07
 * @Version :v1.0.0
 * ClassName:AdminController
 * Package  :com.briup.sms.web.controller
 * Description:TODO
 */
@RestController
@RequestMapping("/admin")
@Api(tags = "管理员相关接口")
@CrossOrigin
public class AdminController {

    @Autowired
    private AdminService service;

    @PostMapping("/login")
    @ApiOperation("管理员登录")
    public Result login(@RequestBody Admin admin) {
        Map map = service.login(admin);
        return Result.success(map);
    }

    @GetMapping("/getInfo")
    @ApiOperation("获取令牌信息")
    public Result getInfo(String token) {
        Admin admin = service.getInfo(token);
        return Result.success(admin);
    }

//    @GetMapping("/getPageUser")
//    @ApiOperation("分页获取用户信息")
//    @ApiImplicitParams(
//            {
//                    @ApiImplicitParam(name="username",value="用户名"),
//                    @ApiImplicitParam(name="stats",value="用户是否禁用",required = false),
//                    @ApiImplicitParam(name="pageSize",value="分页每页数据条数",required = true),
//                    @ApiImplicitParam(name="pageNum",value="页码",required = true)
//            }
//    )
//    public Result getPageUser(String username, Boolean stats, Integer pageSize, Integer pageNum){
//        PageInfo<Admin> admins=service.getPageUser(username,stats,pageSize,pageNum);
//        return Result.success(admins);
//    }
//
//    @PostMapping("/saveUser")
//    @ApiOperation("新增/修改用户信息")
//    public Result save(@RequestBody Admin admin){
//        service.saveUser(admin);
//        return Result.success();
//    }

    /**
     * 退出登录
     *
     * @return
     */
    @ApiOperation("退出登录")
    @PostMapping("/logout")
    public Result<String> logout() {
        return Result.success();
    }
}
